import type { ComponentType, ReactNode } from "react";
import React from "react";

import { Suspense, lazy } from "react";
//import { Spin } from "antd";

/**
 * @description 路由懒加载
 * @param {Element} importComponent 需要访问的组件
 * @returns {ReactNode}
 */
export const lazyLoad = (
  importComponent: () => Promise<{ default: ComponentType }>
): ReactNode => {
  const Component = lazy(importComponent);
  return (
    <Suspense
      fallback={
        // <Spin
        //   size="large"
        //   style={{
        //     display: "flex",
        //     alignItems: "center",
        //     justifyContent: "center",
        //     height: "100%"
        //   }}
        // />
        <div>kkk</div>
      }
    >
      <Component />
    </Suspense>
  );
};

export default lazyLoad;
